package com.spzx.product.api.fallback;

import com.spzx.common.core.domain.R;
import com.spzx.product.api.RemoteProductService;
import com.spzx.product.api.domain.ProductSkuVo;
import com.spzx.product.api.domain.SkuPriceVo;
import org.springframework.cloud.openfeign.FallbackFactory;

import java.util.List;

//@Component
public class RemoteProductFallbackFactory implements FallbackFactory<RemoteProductService> {
    @Override
    public RemoteProductService create(Throwable throwable) {
        return new RemoteProductService() {
            @Override
            public R<ProductSkuVo> getProductSku(Long skuId, String source) {
                return R.fail("获取商品sku失败" + skuId + "：" + throwable.getMessage());
            }

            @Override
            public R<SkuPriceVo> getSkuPrice(Long skuId, String source) {
                return R.fail("获取商品sku价格失败:" + throwable.getMessage());
            }

            @Override
            public R<List<SkuPriceVo>> getSkuPriceList(List<Long> skuIdList, String source) {
                return R.fail("获取商品sku价格列表失败:" + throwable.getMessage());
            }
        };
    }
}
